/**
 * @author chenqb
 * @version 1.0
 * @description: 测试类
 * @date 2024/7/25 10:55
 */
public class MutexDemo {

    private static Mutex mutex = new Mutex();


    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
         Thread thread  = new Thread(
                    () -> {
                        mutex.lock();

                        try {
                            Thread.sleep(3000);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        } finally {
                            mutex.unlock();
                        }

                    }
            );

         thread.start();
        }
    }


}
